#ifndef _MIFPARSER_HPP_
#define _MIFPARSER_HPP_

#include "mif.h"
#include "PrimitiveStream.hpp"
#include "Analyst.hpp"

namespace ModuleEMapData
{

  const int LINE_MAX_BYTES = 80;

  // 图元类型
  enum {
    PRIMITIVE_POINT = 0,
    PRIMITIVE_LINE,
    PRIMITIVE_POLYLINE,
    PRIMITIVE_REGION,
    PRIMITIVE_ARC,
    PRIMITIVE_TEXT,
    PRIMITIVE_RECT,
    PRIMITIVE_ROUNDRECT,
    PRIMITIVE_ELLISPE,

    PRIMITIVE_COUNT
  };

  class MIFparser: public PrimitiveStream
  {
  public:
    MIFparser( std::ifstream& map_file ) throw(StreamError);

    bool               eof( void ) const;
    MIFparser&         operator>>( primitive& p ) throw(StreamError);

    virtual            ~MIFparser( );
  private:

    bool               parse_head( void );
    void               parse_data( void );


    std::ifstream     &ifile;
    Token             cur_token;

    // 不同类型的图元使用不同的处理函数
    typedef  void  (*primitive_parser)( std::ifstream&, primitive&, Token& );
    primitive_parser  primitive_loader[ PRIMITIVE_COUNT ];
  };


}
#endif//_MIFPARSER_HPP_				\
